#include<iostream>
using namespace std;
const int N = 110;
char a[N][N];
int n, m;
int main()
{
	cin >> n >> m;
	for (int i = 1;i <= n;i++)
	{
		for (int j = 1;j <= m;j++)
		{
			cin >> a[i][j];
		}
	}
	for (int i = 1;i <= n;i++)
	{
		for (int j = 1;j <= m;j++)
		{
			if (a[i][j] == '*')
			{
				cout << '*';
			}
			else
			{
				int s = 0;
				for (int dx = -1;dx <=1;dx++)
				{
					for (int dy = -1;dy <= 1;dy++)
					{

						if (a[i + dx][j + dy]=='*')
						{
							s++;
						}
					}
				}
				cout << s ;
			}
		}
		cout << endl;
	}
}